home *** CD-ROM | disk | FTP | other *** search
- Path: digex.net!not-for-mail
- From: jdc@access2.digex.net (John Cochran)
- Newsgroups: comp.lang.c
- Subject: Re: Q.: How does strtol() handles overflows?
- Date: 9 Jan 1996 22:55:19 -0500
- Organization: Express Access Online Communications, Greenbelt, MD USA
- Message-ID: <4cvdb7$4ml@access2.digex.net>
- References: <4cuc2h$gup@news.netvision.net.il>
- NNTP-Posting-Host: access2.digex.net
-
- In article <4cuc2h$gup@news.netvision.net.il>,
- Ami Simchoni <simchoni@netvision.net.il> wrote:
- >Hi,
- >
- >I am trying to make a rubust ascii-to-decimal function which handles
- >input errors and overflows. I want to rely on the standard library as
- >much as possible.
- >
- >Borland C++ 3.1 and 4.02 doumentation says if an overflow occurs strtol
- >just returns zero - which is not satisfactory, of course.
- >
- >The BC++3.1 library source which I have, however, sets errno to ERANGE
- >and returns LONG_MIN or LONG_MAX on overflow. This appears both in the
- >code and in the comments.
- >
- >Does anybody know what the standard says about it?
- >
- >Thanks,
- >Uri.
- >
-
- Section 7.10.1.5 under returns:
-
- The strtol function returns the converted value, if any. If no conversion
- could be performed, zero is returned. If the correct value is outside the
- range of representable values, LONG_MAX or LONG_MIN is returned (according
- to the sign of the value), and the value of the macro ERANGE is stored in
- errno.
-
-
-